<div class="page-header">
    <h1>
        Detail Pembelian Product
        <small>
            <i class="icon-double-angle-right"></i>
            Detail Pembelian Product 
        </small>
    </h1>
</div>

<?php
if ($this->errmsg) {
    ?>
    <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert">
            <i class="icon-remove"></i>
        </button>

        <strong>
            <i class="icon-remove"></i>
            Error
        </strong>

        <?php echo $this->errmsg; ?>
        <br />
    </div>
    <?php
}

if ($this->msg) {
    ?>
    <div class="alert alert-info">
        <button type="button" class="close" data-dismiss="alert">
            <i class="icon-remove"></i>
        </button>

        <strong>
            <i class="icon-ok"></i>
        </strong>

        <?php echo $this->msg; ?>
        <br />
    </div>
    <?php
}

if (!$this->msg && !$this->errmsg) {
    ?>

    <div class="row">
        <div class="col-xs-11">
            <form id="formPD" class="form-horizontal" role="form" action="" method="post">
                <div class="form-group">
                    <label class="col-sm-2 control-label no-padding-right" for="acc_num"> Tanggal Transaksi </label>

                    <div class="col-sm-9">
                        <input readonly="" type="text" id="trans_dtm" name="trans_dtm" value="<?php echo $this->data['trans_dtm']; ?>" class="col-xs-10 col-sm-5" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label no-padding-right" for="acc_num"> Kode Transaksi </label>

                    <div class="col-sm-9">
                        <input readonly="" type="text" id="trans_dtm" name="trans_dtm" value="<?php echo $this->data['trans_code']; ?>" class="col-xs-10 col-sm-5" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label no-padding-right" for="acc_num"> Dari Nomor Akun </label>

                    <div class="col-sm-9">
                        <input readonly="" type="text" id="acc_num" name="acc_num" value="<?php echo $this->data['account_num1']; ?>" class="col-xs-10 col-sm-5" />
                    </div>
                </div>
            <div class="form-group">
                <label class="col-sm-2 control-label no-padding-right" for="tarik"> Jumlah Pembelian </label>

                <div class="col-sm-9">
                    <input type="text" id="tarik" name="tarik" class="col-xs-10 col-sm-5" value="<?php echo $this->data['jumlah']; ?>" readonly />
                </div>
            </div>
           
            <div class="form-group">
                <label class="col-sm-2 control-label no-padding-right" for="bank_name"> Total </label>

                <div class="col-sm-9">
                    <input type="text" id="bank_name" name="bank_name" class="col-xs-10 col-sm-5" value="<?php echo $this->data['amount1']; ?>" readonly />
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label no-padding-right" for="bank_name"> Cara Pembayaran </label>

                <div class="col-sm-9">
                    <input type="text" id="bank_name" name="bank_name" class="col-xs-10 col-sm-5" value="<?php echo $this->data['carabayar']; ?>" readonly />
                </div>
            </div>
                <br>
            <table id="grid-table2"></table>
            <div id="grid-pager2"></div>
            
            <div class="clearfix form-actions">
                <div class="col-md-offset-3 col-md-9">
                    <input type="hidden" name="transId" value="<?php echo $this->transId; ?>">
                    <input type="hidden" name="flag" id="flag" value="">
                    <button class="btn btn-success" type="button" onclick="btnClick('APPROVE')">
                        <i class="icon-ok bigger-110"></i>
                        Approve
                    </button>

                    &nbsp; &nbsp; &nbsp;
                    <button class="btn" type="button" onclick="btnClick('BATALKAN')">
                        <i class="icon-undo bigger-110"></i>
                        Batalkan
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>

<script>

    function btnClick(flag){
        $('#flag').val(flag);

        bootbox.confirm(flag+' Pembelian Product?', function(result) {
                if(result) {
                    $('#formPD').submit();
                }
        });
    }


    jQuery("#grid-table2").jqGrid({
        url:'<?php echo $this->url() ?>/../../jsondata/transdetailproduct?transId=<?php echo $this->transId; ?>',
        datatype: "json",
        height: 100,
        colNames:['No','Suplier','Agen','Nama Produk','Harga','Jumlah','Total'],
        colModel:[ {name:'no',index:'no', sorttype:"int", hidden:true},
                   {name:'suplier',index:'suplier', width:90, editable: false},
                   {name:'agent',index:'agent', width:90, editable: false},
                   {name:'prodname',index:'product_name', editable: false},
                   {name:'price',index:'price', width:90, sorttype:"int", align:"right", formatter: 'number', summaryType:'sum'},
                   {name:'qty',index:'qty', width:90, sorttype:"int", align:"right", formatter: 'number', summaryType:'sum'},
                   {name:'total',index:'total', width:90, sorttype:"int", align:"right", formatter: 'number', summaryType:'sum'}],

        autowidth: true,
        rownumbers: true,
        viewrecords: true,
        caption:"Data Pembelian"

    });

</script>

<?php } ?>